package spec.ecore;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.impl.EClassImpl;
import org.eclipse.emf.ecore.impl.EPackageImpl;

public class EcorePackage {

	private String name;
	private HashMap<String, EcoreClass> class_List;

	public EcorePackage(String name, EPackageImpl ePack) {
		this.name = name;
		class_List = new HashMap<String, EcoreClass>();

		for (EClassifier eClass : ePack.getEClassifiers()) {
			if (eClass instanceof EClassImpl) {
				EcoreClass ecClass = new EcoreClass((EClassImpl) eClass);
				class_List.put(ecClass.getName(), ecClass);
			}
		}
	}

	public String getName() {
		return name;
	}

	public ArrayList<String[]> searchVariable(String className, String methodName) {
		if (class_List.size() > 0) {
			return class_List.get(className).getAttrVar();
		}

		return null;
	}

	public ArrayList<String[]> searchParamVariable(String className, String methodName) {
		if (class_List.size() > 0) {
			return (ArrayList<String[]>) class_List.get(className).getParamVariable(methodName);
		}

		return null;
	}

	public Collection<EcoreClass> getAllClass() {
		return class_List.values();
	}
}
